#ifndef SHAPEVIEW_H
#define SHAPEVIEW_H

#include "qsfmlcanvas.h"
#include <Shinygami/spriteanimate.hpp>
#include <Shinygami/exception.hpp>
#include <QDebug>
class ShapeView : public QSFMLCanvas
{
    Q_OBJECT
public:
    explicit ShapeView(QWidget *parent = 0);

    void SetTexture(const sf::Texture& texture);

    Shiny::SpriteAnimate& GetSpriteAnimate(void)
    {
        return (currentSprite);
    }

    void OnUpdate()
    {
      currentSprite.Update();
      Clear(sf::Color(0, 0, 0));
      Draw(currentSprite);
      foreach (sf::Shape* shape, shapes)
        Draw(*shape);
    }

    void AddShape(sf::Shape* shape);

    void DelShape(sf::Shape* shape)
    {
        shapes.removeAll(shape);
    }

    void ClearShapes(void)
    {
        shapes.clear();
    }

    void SelectShape(int it)
    {
        currentShape = shapes.at(it);
    }

signals:
    void Clicked(QPoint);
    
private:
    void              mouseReleaseEvent(QMouseEvent*);

    Shiny::SpriteAnimate currentSprite;
    QList<sf::Shape*>    shapes;
    sf::Shape*           currentShape;
};

#endif // SHAPEVIEW_H
